import http from '@/utils/http'

const userApi = '/auth'

/** 获取手机验证码-接口 /auth/captcha
 * @param phone 手机号
 * @param type Number 	验证码类型：'1登录','2重置密码'
 */
export const postPhoneCodeApi = (data) => {
  return http({
    method: 'post',
    url: userApi + '/captcha',
    data,
  })
}

/** 短信验证码登录-接口 /auth/login/captcha */
export const postCodeLoginApi = (data) => {
  return http({
    method: 'post',
    url: userApi + '/login/captcha',
    data,
  })
}

/** 密码登录-接口 /auth/login/password */
export const postPawLoginApi = (data) => {
  return http({
    method: 'post',
    url: userApi + '/login/password',
    data,
  })
}

/** 退出登录-接口 /auth/logout */
export const deleteLoginOutApi = (data) => {
  return http({
    method: 'delete',
    url: userApi + '/logout',
    data,
  })
}

/** 刷新令牌-接口 /auth/refresh */
export const postRefreshApi = (data) => {
  return http({
    method: 'post',
    url: userApi + '/refresh',
    data,
  })
}

/** 重置密码-接口 /auth/reset/password */
export const postResetApi = (data) => {
  return http({
    method: 'post',
    url: userApi + '/reset/password',
    data,
  })
}

/** 判断用户登录的浏览器唯一id是否存在于数据库-接口 /auth/login/method */
export const getVisitorIdApi = (params) => {
  return http({
    method: 'get',
    url: userApi + '/login/method',
    params,
  })
}

/** 获取用户信息-接口/auth/user */
export const getUserInfoApi = (params) => {
  return http({
    method: 'get',
    url: userApi + '/user',
    params,
  })
}

/** 获取用户绑定的设备列表-接口 /operation/personal/machine/list */
export const getUserMachineListApi = (params) => {
  return http({
    method: 'get',
    url: '/operation/personal/machine/list',
    params,
  })
}

/**
 * 修改饭宝的在线状态-接口 /operation/personal/machine/state
 * @param machineId 设备id string
 * @param status 状态 在线状态{0：否，1：在线} number
 */
export const putMachineStateApi = (data) => {
  return http({
    method: 'put',
    url: '/operation/personal/machine/state',
    data,
  })
}

// 获取openid
export const getConfigApi = (params) => {
	return http({
		url: '/operation/device/config',
		method: 'get',
    params
	})
}
// 核销实物券
export const verificationApi = (ccId) => {
	return http({
		url: '/operation/device/verification?ccId=' + ccId,
		method: 'post'
	})
}
